import axios, { type AxiosRequestConfig, type RawAxiosRequestHeaders } from 'axios'

const http = axios.create({
    baseURL: 'http://121.89.205.189:3000/admin/',
    timeout: 30 * 1000
})
// 添加请求拦截器
http.interceptors.request.use(function (config: AxiosRequestConfig) {
    let token = sessionStorage.getItem('token')
    if (token) {
        (config.headers as RawAxiosRequestHeaders).token = token
    }
    return config
})

// 添加响应拦截器
http.interceptors.response.use(function (response) {
    return response
})

export default http